<template>
<div id="app">
  <el-breadcrumb separator-class="el-icon-arrow-right">
    <el-breadcrumb-item v-for="breadCrumbItem in breadCrumbList" :key="breadCrumbList.path">
      {{breadCrumbItem.meta.title}}
    </el-breadcrumb-item>
  </el-breadcrumb>

  <el-card>

    <el-table
        :data="rightList"
        stripe
        border
        style="width: 100%"
        lazy>
      <el-table-column  type="index" label="#" ></el-table-column>
      <el-table-column prop="authName" label="权限名称" ></el-table-column>
      <el-table-column prop="path" label="路径" ></el-table-column>
      <el-table-column prop="level" label="权限等级">
        <template v-slot="scope">
          <el-tag v-if="scope.row.level==='0'">一级</el-tag>
          <el-tag type="success" v-else-if="scope.row.level==='1'">二级</el-tag>
          <el-tag type="warning" v-else="scope.row.level==='2'">三级</el-tag>
        </template>
      </el-table-column>
    </el-table>
  </el-card>
</div>
</template>

<script>
export default {
  name: "Right",
  data(){
    return{
      rightList:[]
    }
  },
  methods:{
    async getRightList(){
      const{data:res}=await this.$http.get('rights/list')
      console.log(res.data)
      if(res.meta.status!==200) return this.$message.error('获取权限列表失败')
      this.rightList=res.data
    }
  },
  created() {
    this.getRightList()
  },
  computed: {
    //路由信息列表
    breadCrumbList() {
      console.log(this.$route)
      return this.$route.matched
    }
  }
}
</script>

<style scoped>
.el-card {
  box-shadow: 4px 4px 10px #cecece !important;
  margin-top: 20px;
}
#app{
  opacity: 0;
  animation: bottomBtn 0.5s linear 100ms forwards;
}
@keyframes bottomBtn {
  to{
    opacity: 1;
  }
  from{
    opacity: 0;
  }
}

</style>
